<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div style="display: flex;">
        <label class="el-form-item-label">物料编码</label>
        <el-input v-model.trim="query.productNo" clearable placeholder="物料编码" style="width: 180px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <div style="margin-left: 5px;">
          <rrOperation :crud="crud" />
          <!-- <el-button type="warning" size="mini" icon="el-icon-refresh-right" class="filter-item" @click="reset">重置</el-button> -->
        </div>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <!-- <el-table-column type="selection" width="55" /> -->
        <el-table-column prop="productNo" label="物料编码" />
        <el-table-column prop="productDescription" label="物料描述" />
        <el-table-column prop="partnerProductNo" label="客户物料编号" />
        <el-table-column prop="receiverName" label="客户" />
        <el-table-column prop="materialType" label="物料类型" />
        <el-table-column prop="inventoryQty" label="库存数量(总的数量)" />
        <el-table-column prop="checkingQty" label="盘点数量(盘点了多少个)" />
        <el-table-column prop="status" label="状态" />
        <el-table-column label="操作" width="100px" align="center">
          <template slot-scope="scope">
            <el-button type="text" @click="checkDetail(scope.row)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudInventoryCheckDetail from '@/api/work/checkOrderDetail'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
// import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, inventoryCheckOrderId: null, productNo: null, productDescription: null, partnerProductNo: null, receiverName: null, materialType: null, inventoryQty: null, checkingQty: null, status: null, createTime: null, createName: null, finishTime: null, updateTime: null, updateName: null }
export default {
  name: 'CheckOrderDetail',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'inventoryCheckDetail', url: 'api/inventoryCheckDetail', idField: 'id', sort: 'id,desc', crudMethod: { ...crudInventoryCheckDetail },
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: true,
        reset: true
      }
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'inventoryCheckDetail:add', 'otherUser'],
        edit: ['admin', 'inventoryCheckDetail:edit', 'otherUser'],
        del: ['admin', 'inventoryCheckDetail:del', 'otherUser']
      },
      rules: {
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      this.query.inventoryCheckOrderId = this.$route.query.inventoryCheckOrderId
      this.query.inventoryCheckCode = this.$route.query.inventoryCheckCode
      return true
    },
    checkDetail(row) {
      this.$router.push(`/storageManagement/materialDetail?inventoryCheckCode=${this.query.inventoryCheckCode}&productNo=${row.productNo}`)
    }
  }
}
</script>

<style scoped>

</style>
